import Vue from 'vue'
import App from './App.vue'
// import './registerServiceWorker'
import router from './router'
import Router from 'vue-router'
import { awaitWrap, myInfo, socketClient, countRanTime } from './utils/tool'
import { statusMap, nodeTypeMaps, duTypeMaps, paramMap } from '@/utils/maps'
import VHead from './components/head'
import VFoot from './components/foot'
import VLayout from './components/layout'
import VImage from './components/module/vImage'
import rowData from './components/module/row-data'

import fileList from './components/module/FileList'
import s3FileList from './components/module/FileList/s3'
import mdPreview from './components/module/FileList/mdPreview'
import VChart from './components/module/chart'
import mediaUploader from './components/module/mediaUploader'


import store from './store'
import wrapUploader from './components/module/wrapUploader'
import uploader from 'vue-simple-uploader'
import VueLazyload from 'vue-lazyload'
import VueClipboard from 'vue-clipboard2'

import AsyncComputed from 'vue-async-computed'

import echarts from 'echarts'
import 'github-markdown-css';
// import './registerServiceWorker'

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
Vue.use(VXETable)

import messesDialog from './utils/messesDialog/index'
import Contextmenu from "vue-contextmenujs"
Vue.use(Contextmenu);
// import VueSocketIO from "vue-socket-io";
// Vue.use(VueSocketIO, 'ws://192.168.56.12:9001/');
// socketClient
let resizeFun = null
const init = function (...args) {
  const shili = echarts.init(...args)
  resizeFun = function () {
    shili.resize()
  }
  window.addEventListener('resize', resizeFun)
  return shili
}
Vue.prototype.$echarts = { ...echarts, init }

import {
  Button,
  Dialog,
  RadioGroup,
  Radio,
  RadioButton,
  Row,
  Col,
  Divider,
  Input,
  Form,
  FormItem,
  Table,
  TableColumn,
  Pagination,
  Select,
  Option,
  Checkbox,
  CheckboxGroup,
  Transfer,
  Message,
  MessageBox,
  Breadcrumb,
  BreadcrumbItem,
  Loading,
  Tabs,
  Switch,
  DatePicker,
  Upload,
  TabPane,
  Popover,
  Tree,
  InputNumber,
  Steps,
  Step,
  Tooltip,
  Collapse,
  CollapseItem,
  Drawer,
  Image,
  Tag,
  Cascader,
  Alert,
  MenuItemGroup,
  MenuItem,
  Menu,
  Submenu,
  Link,
  Dropdown,
  DropdownItem,
  DropdownMenu,
  Progress,
  Slider,
  Popconfirm
} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

export let bus = new Vue()

Vue.use(Button);
Vue.use(Dialog);
Vue.use(Row);
Vue.use(Col);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(RadioButton);
Vue.use(Input);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Pagination);
Vue.use(Select);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Transfer);
Vue.use(Option);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Loading);
Vue.use(Tabs);
Vue.use(Switch);
Vue.use(DatePicker);
Vue.use(Upload);
Vue.use(TabPane);
Vue.use(Popover);
Vue.use(Tree);
Vue.use(InputNumber);
Vue.use(Steps);
Vue.use(Step);
Vue.use(Tooltip);
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(Drawer);
Vue.use(Image);
Vue.use(Cascader);
Vue.use(Divider);
Vue.use(Tag);
Vue.use(Alert);
Vue.use(Submenu);
Vue.use(Menu);
Vue.use(MenuItemGroup);
Vue.use(MenuItem);
Vue.use(Link);
Vue.use(Dropdown);
Vue.use(DropdownItem);
Vue.use(DropdownMenu);
Vue.use(Progress);
Vue.use(Slider);
Vue.use(Popconfirm);
Vue.use(uploader);

Vue.config.productionTip = false
// Vue.use(ElementUI);

VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
Vue.use(AsyncComputed)
Vue.directive('append', {
  bind(el, binding) {
    let options = binding.value.options
    let ele = binding.value.el
    for (let i in options) {
      ele[i] = options[i]
    }
    if (!options.value) {
      ele.value = binding.value.options.defaultValue
    }
    ele.tempValue = ele.value
    el.appendChild(ele.$mount(document.createElement("div")).$el)
  }
})
Vue.prototype.$msg = {}
Vue.prototype.$indexReload = 0
Vue.prototype.$isFirstPage = true
Vue.prototype.$message = Message;
Vue.prototype.$messageBox = MessageBox;
Vue.prototype.$messesDialog = messesDialog;
Vue.prototype.$isDel = async function (str) {
  return await messesDialog({
    message: str ? str : `是否删除 ?`,
  })
}

Vue.prototype.$awaitWrap = awaitWrap
Vue.prototype.$myInfo = myInfo
Vue.prototype.$EventBus = bus
Vue.prototype.VUE_APP_USER = process.env.VUE_APP_USER
Vue.prototype.VUE_APP_PUBLICPATH = process.env.VUE_APP_PUBLICPATH
Vue.prototype.VUE_APP_VERSIONS = process.env.VUE_APP_VERSIONS
let IsDarkHue = (process.env.VUE_APP_VERSIONS == 'delta' || process.env.VUE_APP_VERSIONS == 'gamma')
let IsAlpha = (process.env.VUE_APP_VERSIONS == 'alpha' || process.env.VUE_APP_VERSIONS == 'gamma')
let isReinforce = process.env.VUE_APP_VERSIONS == 'beta' || process.env.VUE_APP_VERSIONS == 'gamma'
Vue.prototype.$IsDarkHue = IsDarkHue
Vue.prototype.$IsAlpha = IsAlpha
Vue.prototype.$isReinforce = isReinforce
Vue.prototype.$AxisColor = IsDarkHue ? '#657186' : '#666'
// socketClient

Vue.prototype.$ws = socketClient;
Vue.prototype.countRanTime = countRanTime
Vue.prototype.statusMap = statusMap
Vue.prototype.paramMap = paramMap
Vue.prototype.nodeTypeMaps = nodeTypeMaps
Vue.prototype.duTypeMaps = duTypeMaps

Vue.prototype.defaultImg = 'this.src="' + require('../src/assets/img/default.png') + '"' //无图的时候，显示默认图片  


Vue.component("VHead", VHead)


Vue.component("VFoot", VFoot)
Vue.component("VImage", VImage)
Vue.component("VLayout", VLayout)

Vue.component("rowData", rowData)
Vue.component('VChart', VChart)
Vue.component('fileList', fileList)
Vue.component('s3FileList', s3FileList)
Vue.component('mdPreview', mdPreview)
Vue.component('wrapUploader', wrapUploader)
Vue.component('mediaUploader', mediaUploader)


Vue.use(Router);

router.afterEach(() => {
  window.scrollTo(0, 0);
})

Vue.use(VueLazyload, {
  error: require('../src/assets/img/default.png'),
  // loading: require('../src/assets/img/image-loadding.gif'),
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
